package com.itboye.shopcar_adapter;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.itboye.core.utils.XImageLoader;
import com.itboye.mengwu.R;
import com.itboye.mengwu.data.model.MePingLunbean;

@SuppressLint("ResourceAsColor") public class PingLunchMeAdapter extends BaseAdapter {
	
	Context context;
	ArrayList<MePingLunbean.MyPingLun> list;

	OnClickListener clickListener;

	public PingLunchMeAdapter(Context context,
			ArrayList<MePingLunbean.MyPingLun> list,
			OnClickListener clickListener) {
		this.context = context;
		this.list = list;
		this.clickListener = clickListener;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}


	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHouder houder;
		if(convertView==null){
			houder=new ViewHouder();
			convertView=LayoutInflater.from(context).inflate(R.layout.item_pinglunwode, null);
			houder.tv_title=(TextView) convertView.findViewById(R.id.tv_title);
			houder.textTime=(TextView) convertView.findViewById(R.id.textTime);
			houder.tv_content=(TextView) convertView.findViewById(R.id.tv_content);
			houder.iv_avatar=(ImageView) convertView.findViewById(R.id.iv_avatar);
			houder.txtPingLunTitle=(TextView) convertView.findViewById(R.id.txtPingLunTitle);
			houder.txtPinglunCountext=(TextView) convertView.findViewById(R.id.txtPinglunCountext);
			houder.tv_QuanMessge=(TextView) convertView.findViewById(R.id.tv_QuanMessge);
			houder.tetPing=(TextView) convertView.findViewById(R.id.tetPing);
			convertView.setTag(houder);
			
		}else{
			houder=(ViewHouder) convertView.getTag();
		}
		XImageLoader.load(list.get(position).getHead(), houder.iv_avatar);
		houder.tv_title.setText(list.get(position).getAuthor());
		houder.tv_content.setText(list.get(position).getComment());
		houder.textTime.setText(new SimpleDateFormat("yyyy-MM-dd HH:ss").format(Long
				.parseLong(list.get(position).getDateline())*1000));
		houder.txtPingLunTitle.setText(list.get(position).getThread_info().getNickname());
		houder.txtPinglunCountext.setText(list.get(position).getThread_info().getMessage());
		houder.tv_QuanMessge.setText("评论了我");
		houder.tv_QuanMessge.setTextColor(R.color.gray);
		
		
		
		houder.tetPing.setTag(R.id.tag_first, position);
		houder.tetPing.setTag(R.id.tag_second, position);
		return convertView;
	}
	class  ViewHouder{
		private TextView tv_title;
		private TextView textTime;
		private TextView tv_content;
	
		
		private ImageView iv_avatar;
		//回复的
		private TextView txtPingLunTitle;
		private TextView txtPinglunCountext;
		
		private TextView tv_QuanMessge;
		private TextView  tetPing;
		
	}
	
}
